<template>
    <div>
       <headNav></headNav>
       <div class="head"></div>
       <div class="content">  
        <div class="list_tit_div">{{listNav[ind].name}}</div>
        <div class="list">
        <div class="list_nav">
            <div v-on:mouseover="handleMouseOver(index)" v-on:mouseout="handleMouseOut(index)" class="list_item" :class="index==ind ? 'list_item_active' : '' " @click="clickListItem(index,item.id)" v-for="(item,index) in listNav" :key="index">
                  {{item.name}}
            </div>
        </div>
              <div class="water_div">
                <vue-waterfall-easy @click="handleWater" :loadingDotCount="0" :reachBottomDistance="30" :gap="10" :width="1400" :imgWidth="340" :imgsArr="imgsArr" @scrollReachBottom="getData">
                <div class="info" slot-scope="props">
                  <p class="infop p1">{{props.value.title}}</p>
                  <p class="infop p2">{{props.value.school}}</p>
                </div>
                </vue-waterfall-easy>

            </div>
        </div>
        </div>
     <footCom></footCom>
       
    </div>
  </template>
  
  <script>
import vueWaterfallEasy from 'vue-waterfall-easy';

import footCom from '@/common/foot.vue';
import headNav from '@/common/headNav.vue';

export default {
    name: 'listPage',
    components:{
     headNav,
     footCom,
     vueWaterfallEasy,
  },
  
    data(){
      return{
        id:0,
        ind:0,
          new_ind:0,
          listNav:[
           {name:'推 荐',id:0,},
           {name:'上城区',id:1,},
           {name:'拱墅区',id:2,},
           {name:'西湖区',id:17,},
           {name:'滨江区',id:23,},
           {name:'萧山区',id:29,},
           {name:'余杭区',id:36,},
           {name:'临平区',id:42,},
           {name:'钱塘区',id:48,},
           {name:'富阳区',id:54,},
           {name:'临安区',id:58,},
           {name:'桐庐县',id:64,},
           {name:'淳安县',id:68,},
           {name:'建德市',id:72,},
           {name:'直属学校',id:3,},
      ],
          imgsArr:[
          ],
          page:1
      }
    },
    created(){
       this.id = this.$route.query.id
       this.ind = this.$route.query.ind
       this.new_ind = this.id
       this.getData()
    },
    methods:{
         // 获取推荐的作品
    getData() {
      this.$axios.get('https://eduvideo.hangzhou.com.cn/api/v1/get_works?area_id='+this.id+'&page=' + this.page)
        .then(res => {
          var arr = []
          res.data.data.data.forEach(item=>{
            var obj = {}
              obj['title' ]= item.title
              obj['school'] = item.school
              obj['id'] = item.id
              // if(item.type==1){
              //   obj['src'] ='https://eduvideo.hangzhou.com.cn' + item.files[0].file_cover
              // }else{
              //   obj['src'] = item.files[0].full_file_path
              // }
              obj.src =item.poster
             arr.push(obj)
            })
            this.imgsArr = this.imgsArr.concat(arr)
            this.page++
        })
    }, 
    handleWater(item,val){
      // window.open(item.href, '_blank');
       this.$router.push({
           path:'/workDetail',
           query:{
            id:val.value.id
           }
       })
    },
        clickListItem(index,id){
            this.ind = index;
            this.id = id;
            this.new_ind = this.ind;
            this.page = 1
            this.getData()
            this.imgsArr = []
    },
    handleMouseOver(index){
      this.ind =index;
    },
    handleMouseOut(){
      this.ind =  this.new_ind 
    },
    }
  }
</script>
  
  <!-- Add "scoped" attribute to limit CSS to this component only -->
  <style scoped>
  .topNav{
    width: 100%;
    height: 65px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
  .nav_con{
    width: 1400px;
    display: flex;
    flex-direction: row;
    justify-content: end;
    align-items: center;
  }
  .nav_con a{
    text-decoration: none;
    font-size: 18px;
    color: #616ed6;
    cursor: pointer;
    letter-spacing: 5px;
  }
  .shu{
    color: #616ed6;
    margin: 0 35px;
  }
  .head{
    width: 100%;
    height: 464px;
    background: url('./../static/images/banner.png') no-repeat center top;
  }
  .content{
    width: 100%;
    height: 1400px;
    background: url('./../static/images/detail_con.png') no-repeat;
    background-size: 100% 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
  }
  .list{
    width: 1400px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
  }
  .list_item_active{
  
    color: #a6ebff !important;
    border: 1px solid #fff;
    border-radius: 20px;
  }
  .list_item:hover{
   
    color: #a6ebff;
    border: 1px solid #fff;
    border-radius: 20px;
    cursor: pointer;
  }
  .list_item{
    width: 100px;
    height: 45px;
    text-align: center;
    line-height: 45px;
    color: transparent;
    background-clip: text;
    background-image: linear-gradient(to right, #fff, #ddf4fc, #a6ebff);
  }
  .list_nav{
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 60px 0;
  }
  .list_img{
    width: 1400px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .img_item{
    width: 340px;
    box-sizing: border-box;
    margin-left: 13px;
  
  }
  .list_img .img_item:nth-child(4n+1){
    margin-left: 0 !important;
  }
  
  .img_item img{
    width: 340px;
    height: auto;
  }
  .list_tit_div{
    width: 333px;
    height: 97px;
    background: url('./../static/images/list_tit_bg.png') no-repeat;
    background-size: 100% 100%;
    text-align: center;
    line-height: 97px;
    color: #fff;
    font-size: 36px;
    font-weight: bolder;
  }
  .infop{
    margin: 0;
    padding: 0;
  }
  .info{
    margin-bottom: 50px;
    background-color: transparent;
    border: none !important;
    box-shadow: none !important;
  }
  .p1{
    margin: 25px 0 20px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    word-wrap: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    width: calc(100% - 7px);
    line-height: 25px;
    padding-left: 7px;
    font-size: 20px;
    color: #fff;
  }
  .p2{
    padding-left: 7px;
    color: #9fc9e2;
    font-size: 18px;
  }
  .water_div{
    width: 1400px;
    height: 1000px;
  
  }
  .water_div>>>.vue-waterfall-easy-container .vue-waterfall-easy a.img-inner-box{
    box-shadow: none !important;
    border-radius:none !important;
    cursor: pointer !important;
  }
  .water_div{
    width: 1400px;
    height: 1000px;
  
  }
  .water_div>>>.vue-waterfall-easy-container::-webkit-scrollbar ,.water_div>>>.vue-waterfall-easy-scroll::-webkit-scrollbar {
    width: 0 !important;
    background-color: #f9f9f9;
  }
  </style>
  